<?php
	namespace Common\Logic;
	use Common\Model\CustomOrderListModel;
	class CustomOrderListLogic extends CustomOrderListModel{
		/*
		* Function:		getCustomOrderListCateList
		* Description:	定制订单明细列表
		* @param:		$page string 起始页
						$filter array 过滤数组
						$pageSize string 每页显示条数
		*/
		public function getCustomOrderListList($page=1,$filter = '',$pageSize=20){
			$conditon = $this->getCustomOrderListFilter($filter);
			return $this->where($conditon)->order('id desc')->limit(($page-1)*$pageSize,$pageSize)->select();
		}
		
		/*
		* Function:get:	getCustomOrderListCateFilter
		* Description:	定制订单明细列表搜索过滤项
		* @param:		$filter array 过滤数组
		*/
		public function getCustomOrderListFilter($filter = ''){
			$conditon = array();
         $conditon['pid'] = 0;
         $conditon['status'] = 1;
         $conditon['is_deleted'] = 0;
			if(!empty($filter['name'])){
				$conditon['cate_name'] = array('like','%'.$filter['name'].'%');
			}
			return $conditon;
		}
		
		/*
		* Function:get:	getCustomOrderListCount
		* Description:	定制订单明细列表总数
		* @param:		$filter array 过滤数组
		*/
		public function getCustomOrderListCount($filter = ''){
			$conditon = $this->getCustomOrderListFilter($filter);
			return $this->where($conditon)->count();
		}
		
		/*
		* Function:		addCustomOrderList
		* Description:	增加定制订单明细
		* @param:		$data array 增加的数组
		*/
		public function addCustomOrderList($data){
			return $this->add($data);
		}
		
		/*
		* Function:		getCustomOrderListInfo
		* Description:	获取定制订单明细信息 by row
		* @param:		$id int ID
		*/
		public function getCustomOrderListInfo($id){
			return $this->where(array('id'=>$id))->find();
		}
		
		/*
		* Function:		updateCustomOrderList
		* Description:	更新定制订单明细
		* @param:		$data array 更新的数组
		*/
		public function updateCustomOrderList($data){
			return $this->save($data);
		}
		
		/*
		* Function:		deleteCustomOrderList
		* Description:	删除定制订单明细
		* @param:		$id int ID
		*/
		public function deleteCustomOrderList($id){
			return $this->where(array('id'=>$id))->delete();
		}
		
		/*
		* Function:		getCustomOrderListAllList
		* Description:	定制订单明细列表
		*/
		public function getCustomOrderListAllList($pid = 0){
			$conditon = [];
			$conditon['status'] = 1;
			$conditon['pid'] = $pid;
			return $this->where($conditon)->select();
		}
	}
?>